//商品全选
window.onload = function() {
    var Checkbox1 = document.getElementById("Checkbox1");

    var newslist1 = document.getElementById("newslist-1");
    var newslist2 = document.getElementById("newslist-2");
    Checkbox1.onclick = function() {
        if (Checkbox1.checked == true) {
            newslist1.checked = true;
            newslist2.checked = true;
        } else {
            newslist1.checked = false;
            newslist2.checked = false;
        }
    }
    newslist1.onclick = function() {
        if (newslist1.checked == false) {
            Checkbox1.checked = false;
        }
    }
    newslist2.onclick = function() {
        if (newslist2.checked == false) {
            Checkbox1.checked = false;
        }
    }
}

//商品加减
$(document).ready(function() {
    var min1 = $("#min1");
    var text_box1 = $("#text_box1");
    var add1 = $("#add1");
    min1.click(function() {
        if (text_box1.val() == 1) {

        } else
            text_box1.attr("value", parseFloat(text_box1.val()) - 1)
    });
    add1.click(function() {

        text_box1.attr("value", parseFloat(text_box1.val()) + 1)
    });


    var min2 = $("#min2");
    var text_box2 = $("#text_box2");
    var add2 = $("#add2");
    min2.click(function() {
        if (text_box2.val() == 1) {

        } else
            text_box2.attr("value", parseFloat(text_box2.val()) - 1)
    });
    add2.click(function() {

        text_box2.attr("value", parseFloat(text_box2.val()) + 1)
    });





    //计算单价

    var text_box1 = $("#text_box1");
    var text_box2 = $("#text_box2")
    var total1 = $("#total1");
    var total2 = $("#total2");

    setInterval(function() {
        total1.text("￥" + parseFloat(text_box1.val()) * 49);
        total2.text("￥" + parseFloat(text_box2.val()) * 49);

        $("#shuliang").text(parseFloat(text_box1.val()) + parseFloat(text_box2.val()));

        $("#zong1").text(parseFloat(text_box1.val()) * 49 + parseFloat(text_box2.val()) * 49)

    }, 100);


    //删除的商品
    var delcart1 = $("#delcart1");
    var delcart2 = $("#delcart2");
    var removecart = $("#removecart");
    delcart1.click(function() {
        delcart1.parent().parent().parent().remove();

    })
    delcart2.click(function() {
        delcart2.parent().parent().parent().remove();
    })
    removecart.click(function() {
        $("#table1").remove();
        $("#table2").remove();

    })

})